<?xml version="1.0" encoding="UTF-8"?> 

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xml:lang="en" version="1.0">
    <xsl:output method="html" encoding="UTF-8"/>
    
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="count(//medium) = 1">
                <xsl:apply-templates />
            </xsl:when>            
        </xsl:choose>
    </xsl:template>
    
    <xsl:template match="medium">
        <tr>   
        
            <td>
                <xsl:value-of select="name"/>
            </td>
    
            <td>
                <xsl:value-of select="@type"/>
            </td>
            <td>           
                <button  class="show-button" >Show Movies</button>
                <div class="movies-hidden" >                    
                    <xsl:element name="table" > 
                        <xsl:attribute name="id">inner-table
                            <xsl:value-of select="@id"/>
                        </xsl:attribute> 
                        <th>Title</th>
                        <th style="width: 15%">Length</th>
                        <th style="width: 5%">La<sup>*</sup></th>
                        <th style="width: 10%">Genre</th>
                        <th style="width: 10%">Format</th>
                        <th style="width: 10%">Note </th>  
                        <xsl:for-each select="movies/movie">                        
                            <tr>
                                <td><xsl:value-of select="title" /></td>
                                <td><xsl:value-of select="length" /></td>
                                <td>
                                    <xsl:value-of select="languages" />
                                </td>
                                <td>
                                    <xsl:value-of select="genre" />
                                </td>
                                <td>
                                    <xsl:value-of select="format" />
                                </td>
                                <td>
                                    <xsl:value-of select="note" />
                                </td>  
                            </tr>
                        </xsl:for-each>     
                        <div id="languages-meaning"><sup>*La is abbreviation for Languages</sup></div>
                    </xsl:element>
                    
                </div>                
            </td>
                       
            <td>
                <xsl:element name="a">                    
                    <xsl:attribute name="href">?action=/Delete&#38;id=<xsl:value-of select="@id"/></xsl:attribute>
                    <span class="ui-icon ui-icon-closethick remove-medium"></span>
                </xsl:element>      
            </td>            
        </tr>       
    </xsl:template>

</xsl:stylesheet>


